package online.sh.cn.fy.shops;

import java.io.IOException;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;
import online.sh.cn.fy.common.utils.CookieUtil;
import online.sh.cn.fy.common.utils.DES3Util;
import online.sh.cn.fy.common.utils.ResponseUtils;
import online.sh.cn.fy.common.utils.TokenUtils;

/**
 * 校园店详情
 */
@WebServlet("/shopDetail")
public class ShopDetailServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doPost(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		String openid=CookieUtil.getCookieValueByName(request, "openid");
		String shopname=request.getParameter("schopname").toString();
		JSONObject json=new JSONObject();
		TokenUtils to=new TokenUtils();
		if(null!=openid && ""!=openid){
			Map schoolshop=to.checkSchoolShopBySchool(shopname);
			json.put("result", "0");
			json.put("shimg", schoolshop.get("shimage").toString());
			json.put("spname", schoolshop.get("shopname").toString());
			json.put("shname", schoolshop.get("schoolname").toString());
			json.put("spaddress", schoolshop.get("shopaddress").toString());
			json.put("sptel", schoolshop.get("shoptel").toString());
			json.put("sphour", schoolshop.get("shopbusinesshour").toString());
			ResponseUtils.renderJson(response, json.toString());
		}else{
			json.put("result", "1");
			ResponseUtils.renderJson(response, json.toString());			
		}
	}

}
